//index.js

const http = require("../../models/http")

//获取应用实例
const app = getApp()

Page({
  data: {
    value:""
  },
  onLoad: function () {
    http({
      url:"http://192.168.4.18:3000/top/playlist?cat=%E5%8D%8E%E8%AF%AD&limit=15&offset=0",
      success:res=>{
        console.log(res.data.playlists);
        this.setData({
          value:res.data.playlists
        })
      }
    })
  },
  onReachBottom(){
    let long = this.data.value.length;
    http({
      url:`http://192.168.4.18:3000/top/playlist?cat=%E5%8D%8E%E8%AF%AD&limit=15&offset=${long}`,
      success:res=>{
        console.log(res.data.playlists);
        let value = [...this.data.value,...res.data.playlists]
        this.setData({
          value:value
        })
      }
    })
  },
  handleToggle(event){
    let id = event.currentTarget.dataset.id
    console.log(id);
    wx.navigateTo({
      url: `../detail/detail?id=${id}`,
      success: function(res){
        // success
      }
    })
  }
})
